package com.heba.popupwindow;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.heba.greenmulu.R;
import com.heba.popupwindow.callback.DiaryAddPhotoCilckListener;

/**
 * 日记图片、视频弹出框
 * Created by shenghao on 2020/02/06.
 */
public class DiaryAddPhotoPopupWindow extends BasePopupWindow implements View.OnClickListener {

    private Button btn_album;
    private Button btn_take_photo;
    private Button btn_take_video;
    private Button btn_cancel;

    private DiaryAddPhotoCilckListener listener;

    public DiaryAddPhotoPopupWindow(Context context) {
        super(LayoutInflater.from(context).inflate(
                R.layout.popup_diary_add_photo, null));
        setAnimationStyle(R.style.Popup_Animation_Translate);
    }

    public DiaryAddPhotoPopupWindow(Context context, int width, int height) {
        super(context, LayoutInflater.from(context).inflate(
                R.layout.popup_diary_add_photo, null), width, height);
        setAnimationStyle(R.style.Popup_Animation_Translate);
    }

    @Override
    public void initViews() {
        btn_album = (Button) findViewById(R.id.btn_album);
        btn_take_photo = (Button) findViewById(R.id.btn_take_photo);
        btn_take_video = (Button) findViewById(R.id.btn_take_video);
        btn_cancel = (Button) findViewById(R.id.btn_cancel);
    }

    @Override
    public void initEvents() {
        btn_album.setOnClickListener(this);
        btn_take_photo.setOnClickListener(this);
        btn_take_video.setOnClickListener(this);
        btn_cancel.setOnClickListener(this);
    }

    @Override
    public void init() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_album:
                if (listener != null)
                    listener.onAlbumClick();
                break;
            case R.id.btn_take_photo:
                if (listener != null)
                    listener.onTakePhotoClick();
                break;
            case R.id.btn_take_video:
                if (listener != null)
                    listener.onTakeVideoClick();
                break;
            case R.id.btn_cancel:
                if (listener != null)
                    listener.onCancelClick();
                break;
            default:
                break;
        }
        dismiss();
    }

    /**
     * 是否显示视频按钮
     *
     * @param isVisble
     */
    public void setVideoVisible(boolean isVisble) {
        btn_take_video.setVisibility(isVisble ? View.VISIBLE : View.GONE);
    }

    /**
     * @param diaryAddPhotoClickListener
     */
    public void setOnDiaryAddPhotoClickListener(DiaryAddPhotoCilckListener diaryAddPhotoClickListener) {
        this.listener = diaryAddPhotoClickListener;
    }

}
